﻿using DevExpress.ExpressApp.Blazor.Editors;
using DevExpress.ExpressApp.Blazor.Editors.Adapters;
using DevExpress.ExpressApp.Model;
using Microsoft.AspNetCore.Components;

namespace EasyXaf.Blazor.ColorPickers;

public class ColorPickerEditor : BlazorPropertyEditorBase
{
    public ColorPickerEditor(Type objectType, IModelMemberViewItem model)
        : base(objectType, model)
    {
    }

    protected override IComponentAdapter CreateComponentAdapter()
    {
        return new ColorPickerAdapter(new ColorPickerModel() { Id = Id });
    }

    protected override RenderFragment CreateViewComponentCore(object dataContext)
    {
        return ColorRenderer.Create(MemberInfo.GetValue(dataContext) + string.Empty);
    }
}
